<?php
namespace app\index\controller;
use think\Db;
use think\Request;
use think\Url;
use think\Session;
use think\Controller;
use app\index\model\Customer as thisModel;

/**
 * 
 */
class Customer extends Base
{
	
	
	public function index()
	{

		$authmenu = new \think\Authmenu();
		$uid = Session::get('manage_id');
		$auth=$authmenu->check($uid,'cust_index');
		if($auth != true){
			$this->error('权限不足');
			exit();
		}
		/*获取客户等级列表*/
		$level = DB::name('customer_level')->field('id,title')->order('orderid asc')->select();
		/*获取客户列表*/
		$where['status'] = 1;
		$where['is_del'] = 0;
		$uid = Session::get('manage_id');
		$shop_id = DB::name('user')->where('id ='.$uid)->value('shop_id');
		/*判断权限  是能看见店铺的呢  还是只有自己的 还是所有*/
		$authmenu = new \think\Authmenu();
		$auth=$authmenu->check($uid,'order_shop');
		if($auth == true){
			$where['shop_id'] = $shop_id;
		} 
		$all = $authmenu->check($uid,'order_person');
		if($all == true){
		$where['user_id'] = Session::get('manage_id');
		}
		if(request::instance()->isPost())//搜索条件
		{
			$name = request::instance()->post('name');
			$where['name'] = array('like','%'.$name.'%');
		}
		$list = DB::name('customer')->where($where)->order('id desc')->paginate(20);
		$page = $list->render();
		$this->assign('page', $page);
		$list = $list->all();
		foreach ($list as $k => $v) {
			$list[$k]['sex']  = $v['sex'] == 1 ? '男' : '女' ;
			$list[$k]['is_New'] = $v['is_New'] == 1 ? '新客户' : '老客户' ; 
			if($v['from'] ==1){
				$list[$k]['from'] = '个人查找';
			}elseif ($v['from'] == 2) {
				$list[$k]['from'] ='老客户转介绍';
			}else{
				$list[$k]['from'] = '公司派单';
			}
			$list[$k]['level'] = DB::name('customer_level')->where('id = '.$v['level'])->value('title');
			$list[$k]['shop'] = DB::name('shop')->where('id = '.$v['shop_id'])->value('title');
			$list[$k]['user_name'] = DB::name('user')->where('id = '.$v['user_id'])->value('truename');
		}
		return $this->fetch('Customer/index',[
			'list' => $list,
			'level' => $level,
		]);
	}


	public function show($id)
	{
		if(request::instance()->post()){
			$data = request::instance()->post();
			$cust = request::instance()->post('cust/a');
			$jing = Request::instance()->post('jing/a');
			$cust['shop_id'] = $jing['shop_id']  = Request::instance()->post('shop_id');
			$cust['user_id'] = $jing['user_id']  = Request::instance()->post('user_id');
		}
		$data = DB::name('customer')->where('id = '.$id)->find();
		$data['first'] = DB::name('order_first')->where('cust_id = '.$id)->find();
		$prov = $this->appendarg();
		$shop = $this->getShopList();
		$level = $this->getLevel();
		$category = $this->getCategory();
		$city = $this->getcity($data['province']);
		$area = $this->getarea($data['city']);
		$user = $this->getUser($data['shop_id']);
		return $this->fetch('Customer/show',[
			'data' 		=> 	$data,
			'prov'		=>	$prov,
			'shop'		=>	$shop,
			'level'		=>	$level,
			'user'		=>	$user,
			'city'		=>	$city,
			'area'		=>	$area,
			'category'	=>	$category,
		]);
	}

	public function delcust()
	{
		if(Request::instance()->isPost())
		{
			$id = Request::instance()->post('id');
			/*判断权限*/
			$authmenu = new \think\Authmenu();
			$uid = Session::get('manage_id');
			$auth=$authmenu->check($uid,'cust_del');
			if($auth !=true){//没有删除菜单的权限
				$res['sta'] = '-1';
				$res['msg'] = '权限不足';
				
			}else{
				$del = DB::name('customer')->where('id = '.$id)->setField('is_del',1);
				if($del){
					$res['sta'] = '1';
					$res['msg'] = '删除成功';
				}else{
					$res['sta'] = '0';
					$res['msg'] = '删除失败';
				}
			}
			return json($res);
		}
	}
		/*获取地址*/
	public function appendarg(){
		$prov_data = db::name('cn_prov')->field('code,name')->select();
		return $prov_data;
	}

	/*获取店铺信息*/
	public function getShopList()
	{
		$shopList = DB::name('shop')->field('id,title')->select();
		return $shopList;
	}

	/*获取用户等级*/
	public function getLevel()
	{
		$levelList = DB::name('customer_level')->field('id,title')->select();
		return $levelList;
	}

		/*获取品类*/
	public function getCategory()
	{
		$categoryList = DB::name('category')->field('id,title')->order('orderid asc')->select();
		return $categoryList;
	}

	/*获取用户姓名*/
	public function getUser($shop_id)
	{
		$userList = DB::name('user')->field('id,truename')->where('shop_id = '.$shop_id)->select();
		return $userList;
	}
	/*获取城市*/
	public function getcity($pcode)
	{
		$city = db::name('cn_city')->field('code,name')->where('pcode',$pcode)->select();
		return $city;
	}
	/*获取地区*/
	public function getarea($pcode)
	{

		$area = db::name('cn_area')->field('code,name')->where('pcode',$pcode)->select();
		return $area;
	}

//========================================CRM:客户管理系统的方法开始====================================================//	
	/* 私海客户*/
	public function privateList()
	{
		/*根据客户名称进行搜索*/
		if(Request::instance()->isPost())
		{
			$name = Request::instance()->post('name');
			$where['name'] = array('like',"%$name%");
		}
		$where['is_del'] = 0;/*没有删除*/
		$where['is_public'] = 0;/*私海客户*/
		$authmenu = new \think\Authmenu();
			$uid = Session::get('manage_id');
			$auth=$authmenu->check($uid,'cust_all');
			if($auth != true){
			$where['ling_id'] = $uid;
			}

		$list = DB::name('cust_yixiang')->where($where)->order('id desc')->paginate(15);
		$page = $list->render();
		$list = $list->all();
		foreach ($list as $k => $v) {
			$list[$k]['level'] = DB::name('customer_level')->where('id = '.$v['level'])->value('title');
			$list[$k]['sex'] = $v['sex'] == 1 ? '男' : '女' ;
			$list[$k]['prov'] = DB::name('cn_prov')->where('code = '.$v['prov'])->value('name');
			$list[$k]['city'] = DB::name('cn_city')->where('code = '.$v['city'])->value('name');
			$list[$k]['area'] = DB::name('cn_area')->where('code = '.$v['area'])->value('name');
			switch ($v['from']) {
				case '1':
					$list[$k]['from'] = '自主开发';
					break;
				case '2':
					$list[$k]['from'] = '进店客户';
					break;
				case '3':
					$list[$k]['from'] = '公司派单';
					break;
			}
			switch ($v['yixiang']) {
				case '-1':
					$list[$k]['yixiang'] = '保密';
					break;
				case 'A':
					$list[$k]['yixiang'] = '关键客户';
					break;
				case 'B':
					$list[$k]['yixiang'] = '主要客户';
					break;
				case 'C':
					$list[$k]['yixiang'] = '普通客户';
					break;
				case 'D':
					$list[$k]['yixiang'] = '一般客户';
					break;
				case 'E':
					$list[$k]['yixiang'] = '死客';
					break;
				case 'F':
					$list[$k]['yixiang'] = '团购意向客户';
					break;					
			}
		}
		return $this->fetch('Customer/private_list',[
			'list'		=>	$list,
			'page'		=>	$page,
		]);
	}

	/*查看私海客户的详细信息*/
	public function showPrivate($id)
	{
		$data = DB::name('cust_yixiang')->where('id = '.$id)->find();
		$data['level'] = DB::name('customer_level')->where('id = '.$data['level'])->value('title');
		$data['sex'] = $data['sex'] == 1 ? '男' : '女' ;
		$data['prov'] = DB::name('cn_prov')->where('code = '.$data['prov'])->value('name');
		$data['city'] = DB::name('cn_city')->where('code = '.$data['city'])->value('name');
		$data['area'] = DB::name('cn_area')->where('code = '.$data['area'])->value('name');
		switch ($data['from']) {
				case '1':
					$data['from'] = '自主开发';
					break;
				case '2':
					$data['from'] = '进店客户';
					break;
				case '3':
					$data['from'] = '公司派单';
					break;
			}
		switch ($data['yixiang']) {
				case '-1':
					$data['yixiang'] = '保密';
					break;
				case 'A':
					$data['yixiang'] = '关键客户';
					break;
				case 'B':
					$data['yixiang'] = '主要客户';
					break;
				case 'C':
					$data['yixiang'] = '普通客户';
					break;
				case 'D':
					$data['yixiang'] = '一般客户';
					break;
				case 'E':
					$data['yixiang'] = '死客';
					break;
				case 'F':
					$data['yixiang'] = '团购意向客户';
					break;		
			}	
		/*查询公司信息*/
		if(!empty($data['comp_id']))
		{
		$comp = DB::name('cust_compinfo')->where('id = '.$data['comp_id'])->find();
		}else{
			$comp = 0;
		}
		/*查询回访记录*/
		$list = DB::name('cust_rows')->where('cust_id ='.$data['id'])->order('id desc')->select();
		foreach ($list as $k => $v) {
			$list[$k]['entry'] = DB::name('user')->where('id ='.$v['entry_id'])->value('truename');
			switch ($v['yixiang']) {
				case '-1':
					$list[$k]['yixiang'] = '保密';
					break;
				case 'A':
					$list[$k]['yixiang'] = '关键客户';
					break;
				case 'B':
					$list[$k]['yixiang'] = '主要客户';
					break;
				case 'C':
					$list[$k]['yixiang'] = '普通客户';
					break;
				case 'D':
					$list[$k]['yixiang'] = '一般客户';
					break;
				case 'E':
					$list[$k]['yixiang'] = '死客';
					break;
				case 'F':
					$list[$k]['yixiang'] = '团购意向客户';
					break;			
			}
			switch ($v['huifang']) {
				case '1':
					$list[$k]['huifang'] = '去电';
					break;
				case '2':
					$list[$k]['huifang'] = '来电';
					break;
				case '3':
					$list[$k]['huifang'] = '上门';
					break;
				case '4':
					$list[$k]['huifang'] = '信息';
					break;
			}
		}
		return $this->fetch('Customer/show_private',[
			'data'		=> 	$data,
			'list'		=>	$list,
			'comp'		=>	$comp,
		]);
	}
	/*公海客户*/
	public function publicList()
	{
		/*根据客户名称进行搜索*/
		$name = input('param.name');
		$cate = input('param.category');
		/*if(Request::instance()->isPost())
		{*/
//			$name = Request::instance()->post('name');
//			$cate = request::instance()->post('category');
			if($cate > -1)
			{
				$where['from']	=	$cate;
			}
			if(!empty($name)){
				//$where['name'] = array('like',"%$name%");
				$entry = DB::name('user')->where("is_del = 0 and truename like '%".$name."%'")->field('id')->select();
				$arr = '';
				foreach($entry as $k=>$v)
				{
					$arr .= $v['id'].',';
				}
				$arr = substr($arr, 0 , -1);
				$where['entry_id'] = array('in', $arr);
			}
		/*}*/
		$where['is_del'] = 0;/*没有删除*/
		/*判断权限，要是有权限的话就查看全部信息，没有权限的话就只能看没人领的客户*/ 
		/*cust_all  查看全部的客户*/
			$authmenu = new \think\Authmenu();
			$uid = Session::get('manage_id');
			$auth=$authmenu->check($uid,'cust_all');
			if($auth != true){
			$where['is_public'] = 1;
			}
		$count = DB::name('cust_yixiang')->where($where)->count();	
		$list = DB::name('cust_yixiang')->where($where)->order('id desc,entry_time desc')->paginate(15,false,['query' => request()->param()]);
		$page = $list->render();
		$list = $list->all();
		foreach ($list as $k => $v) {
			$list[$k]['level'] = DB::name('customer_level')->where('id = '.$v['level'])->value('title');
			$list[$k]['entry'] = DB::name('user')->where('id = '.$v['entry_id'])->value('truename');
			$list[$k]['ling'] = DB::name('user')->where('id = '.$v['ling_id'])->value('truename');
			/*$list[$k]['public'] = $list[$k]['is_public'] == 1 ? '公海客户': '私海用户' ;*/
			switch ($v['from']) {
				case '1':
					$list[$k]['from'] = '自主开发';
					break;
				case '2':
					$list[$k]['from'] = '进店客户';
					break;
				case '3':
					$list[$k]['from'] = '公司派单';
					break;
			}
			switch ($v['yixiang']) {
				case '-1':
					$list[$k]['yixiang'] = '保密';
					break;
				case 'A':
					$list[$k]['yixiang'] = '关键客户';
					break;
				case 'B':
					$list[$k]['yixiang'] = '主要客户';
					break;
				case 'C':
					$list[$k]['yixiang'] = '普通客户';
					break;
				case 'D':
					$list[$k]['yixiang'] = '一般客户';
					break;
				case 'E':
					$list[$k]['yixiang'] = '死客';
					break;
				case 'F':
					$list[$k]['yixiang'] = '团购意向客户';
					break;			
			}
		}
		return $this->fetch('Customer/public_list',[
			'list'		=>	$list,
			'page'		=>	$page,
			'count'		=>	$count,
		]);
	}

	/*删除客户  只是修改状态 不删除数据*/
	public function deleteCustomer()
	{
		if(Request::instance()->isPost())
		{
			$id = Request::instance()->post('id');
			/*判断权限*/
			$authmenu = new \think\Authmenu();
			$uid = Session::get('manage_id');
			$auth=$authmenu->check($uid,'cust_deleteCustomer');
			if($auth !=true){//没有删除菜单的权限
				$res['sta'] = '-1';
				$res['msg'] = '权限不足';
				
			}else{
				$del = DB::name('cust_yixiang')->where('id = '.$id)->setField('is_del',1);
				if($del){
					$res['sta'] = '1';
					$res['msg'] = '删除成功';
				}else{
					$res['sta'] = '0';
					$res['msg'] = '删除失败';
				}
			}
			return json($res);
		}
	}
	/*修改客户状态*/
	public function changeStatus()
	{
		if(Request::instance()->isPost())
		{
			$id = Request::instance()->post('id');
			$data['status'] = Request::instance()->post('status');
			if($data['status'] == 0){
				$data['is_public'] = 1;
			}
			$result = DB::name('cust_yixiang')->where('id ='.$id)->setField($data);
			if($result){
				$res['sta'] = '1';
				$res['msg'] = '删除成功'; 
			}else{
				$res['sta'] = '0';
				$res['msg'] = '删除失败';
			}
			return json($res);
		}
	}
	/*发布客户*/
	public function  privateCreate()
	{
		if(Request::instance()->isPost())
		{
			$pub = Request::instance()->post('pub/a');
			$comp = Request::instance()->post('comp/a');
			$pub['entry_id'] = $pub['ling_id'] = Session::get('manage_id');
			$pub['entry_time'] = $pub['ling_time'] = $pub['last_time'] = time();//录入时间你 领取时间  最后回访时间	
			/*判断有没有公司信息 要是没有的话就不在公司表中插入 要是有的话才插入*/	
			if($comp['name']!= '' && $comp['phone']!='' && $comp['address']!='' && $comp['hangye']!='' && $comp['code']!='')
			{
				$comp['addtime'] = time();
				$company = DB::name('cust_compinfo')->insertGetId($comp);
				if($company)//说明公司信息插入成功
				{
					$pub['comp_id'] = $company;
				}
			}
			$res = DB::name('cust_yixiang')->insert($pub);
			if($res)
			{
				$this->success('创建客户成功',url('index/index/index',array('con'=>'customer','act'=>'privateList')));
			}
		}
		$prov = $this->appendarg();
		$level = $this->getLevel();
		return $this->fetch('Customer/private_create',[
			'prov'		=>	$prov,
			'level'		=>	$level,
		]);
	}

	/*修改客户信息*/ 
	public function privateUpdate($id)
	{
		if(Request::instance()->isPost())
		{
			$pub = Request::instance()->post('pub/a');
			$comp = Request::instance()->post('comp/a');
			$comp_id = Request::instance()->post('comp_id');
			/*判断公司信息有没有 要是有的话 就修改 要是没有的话就添加*/	
			if(!empty($comp_id))
			{
				$company = DB::name('cust_compinfo')->where('id ='.$comp_id)->setField($comp);
			}else{
				$comp['addtime'] = time();
				$company = DB::name('cust_compinfo')->insertGetId($comp);
				$pub['comp_id'] = $company;
			}
			/*修改客户的信息*/
			$res = DB::name('cust_yixiang')->where('id ='.$id)->setField($pub);
			if($res)
			{
				$this->success('修改信息成功',url('index/index/index',array('con'=>'customer','act'=>'privateList')));
			}
		}
		$data = DB::name('cust_yixiang')->where('id = '.$id)->find();
		if(!empty($data['comp_id']))
		{
			$comp = DB::name('cust_compinfo')->where('id = '.$data['comp_id'])->find();
			$this->assign('comp',$comp);
		}
		$prov  = $this->appendarg();
		$level = $this->getLevel();
		$city  = $this->getcity($data['prov']);
		$area  = $this->getarea($data['city']);
		return $this->fetch('Customer/private_create',[
			'data'		=>	$data,
			'prov'		=>	$prov,
			'level'		=>	$level,
			'city'		=>	$city,
			'area'		=>	$area,
		]);
	}
	/*添加回访记录*/
	public function addRow()
	{
		if(Request::instance()->isPost())
		{
			$data = Request::instance()->post();
			$data['entry_id'] = Session::get('manage_id');
			$data['addtime'] = $cust['last_time'] = time();
			$cust['yixiang'] = $data['yixiang'];
			$res = DB::name('cust_rows')->insert($data);
			if($res)//插入回访记录
			{
			  $resault = DB::name('cust_yixiang')->where('id ='.$data['cust_id'])->setField($cust);
			  if($resault)
			  {
			  	$this->success('维护记录添加成功',url('index/index/index',array('con'=>'customer','act'=>'privateList')));
			  }
			}
		}
	}

	/*将私海的客户转移到公户*/
	public function goPublic($attr)
	{
		$where['id'] = array('in',$attr);
		$data['is_public'] = 1;
		$data['status'] = 0;
		$res = DB::name('cust_yixiang')->where($where)->setField($data);
		if($res)
		{
			$this->success('转移成功',url('index/index/index',array('con'=>'customer','act'=>'privateList')));
		}
	}

	/*将公海客户转移到私海*/
	public function goPrivate($attr)
	{

		$where['id'] = array('in',$attr);
		$data['is_public'] = 0;
		$data['ling_id'] = Session::get('manage_id');
		$data['ling_time'] = $data['last_time'] =  time();
		$data['status']	=	1;
		$res = DB::name('cust_yixiang')->where($where)->setField($data);
		if($res)
		{
			$this->success('转移成功',url('index/index/index',array('con'=>'customer','act'=>'publicList')));
		}else{
			$this->error('转移失败');
		}
	}

	/*回访信息*/
	public function message($id)
	{
		$public = DB::name('cust_yixiang')->where('id = '.$id)->value('is_public');
		/*判断是不是公海客户 要是是私海客户 在判断权限 只有有权限才能查看*/
		/*cust_message  查看私海记录*/
		if($public == 0)
		{
			$authmenu = new \think\Authmenu();
			$uid = Session::get('manage_id');
			$auth=$authmenu->check($uid,'cust_message');
			if($auth != true){
			$this->error('权限不足');
			exit();
			}
		}
		$list = DB::name('cust_rows')->where('cust_id ='.$id)->order('id desc')->select();
		foreach ($list as $k => $v) {
			$list[$k]['entry'] = DB::name('user')->where('id ='.$v['entry_id'])->value('truename');
			switch ($v['yixiang']) {
				case '-1':
					$list[$k]['yixiang'] = '保密';
					break;
				case 'A':
					$list[$k]['yixiang'] = '关键客户';
					break;
				case 'B':
					$list[$k]['yixiang'] = '主要客户';
					break;
				case 'C':
					$list[$k]['yixiang'] = '普通客户';
					break;
				case 'D':
					$list[$k]['yixiang'] = '一般客户';
					break;
				case 'E':
					$list[$k]['yixiang'] = '死客';
					break;
				case 'F':
					$list[$k]['yixiang'] = '团购意向客户';
					break;			
			}
			switch ($v['huifang']) {
				case '1':
					$list[$k]['huifang'] = '去电';
					break;
				case '2':
					$list[$k]['huifang'] = '来电';
					break;
				case '3':
					$list[$k]['huifang'] = '上门';
					break;
				case '4':
					$list[$k]['huifang'] = '信息';
					break;
			}
		}
		return $this->fetch('Customer/message',[
			'list'		=>	$list,
		]);
	}

	/*导出私海数据方法*/
	public function export($attr=null)
	{
		$name='私海客户列表';
		$header=['客户名称','性别','联系方式','客户等级','客户意向','客户来源','客户行业','联系地址','创建时间'];
		$where['is_del'] = 0;
		if(!empty($attr)){
			$where['id'] = array('in',$attr);
		}
		/*获取到id 然后查询这些id所对应的信息 最后放在表格里面*/
		$list = DB::name('cust_yixiang')->where($where)->order('id desc')->select();
		$str = array();
		foreach ($list as $k => $v) {
			$v['sex'] = $v['sex'] == 1 ? '男' : '女';
			$v['level'] = DB::name('customer_level')->where('id = '.$v['level'])->value('title');
			switch ($v['from']) {
				case '1':
					$v['from'] = '自主开发';
					break;
				case '2':
					$v['from'] = '进店客户';
					break;
				case '3':
					$v['from'] = '公司派单';
					break;
			}
			switch ($v['yixiang']) {
				case '-1':
					$v['yixiang'] = '保密';
					break;
				case 'A':
					$v['yixiang'] = '关键客户';
					break;
				case 'B':
					$v['yixiang'] = '主要客户';
					break;
				case 'C':
					$v['yixiang'] = '普通客户';
					break;
				case 'D':
					$v['yixiang'] = '一般客户';
					break;
				case 'E':
					$v['yixiang'] = '死客';
					break;
				case 'F':
					$v['yixiang'] = '团购意向客户';
					break;		
			}
			$prov = DB::name('cn_prov')->where('code = '.$v['prov'])->value('name');
			$city = DB::name('cn_city')->where('code = '.$v['city'])->value('name');
			$area = DB::name('cn_area')->where('code = '.$v['area'])->value('name');
			$v['dizhi'] = $prov.$city.$area.$v['address'];
			$v['addtime'] = date('Y-m-d H:i:s',$v['entry_time']);
			$str[] = [$v['name'],$v['sex'],$v['phone'],$v['level'],$v['yixiang'],$v['from'],$v['hangye'],$v['dizhi'],$v['addtime']];
			}
			$data=$str;
			excelExport($name,$header,$data);
	}
	/**/
	public function  sendSms()
	{
		$authmenu = new \think\Authmenu();
		$uid = Session::get('manage_id');
		$auth=$authmenu->check($uid,'cust_sendSms');
		if($auth != true){
			$this->error('权限不足');
		}

			$data =  DB::name('customer')->where('is_del = 0 and length(phone) = 11')->field('phone,name')->group('phone')->order('id')->select();
		foreach($data as $k=>$v){
			$send = send_sms($v['phone'], 1, ['code'=>$v['name']]);
			if($send['Message'] != 'OK'){
				$this->error($v['name'].'的电话号有问题');
				//return false;
			}
		}if($send['Message'] == 'OK'){
			$this->success('发送成功',url('index/index/index',array('con'=>'customer','act'=>'index')));
		}
	}
	/*给公海全部客户发信息*/
	public function sendPublicSms()
	{
		$authmenu = new \think\Authmenu();
		$uid = Session::get('manage_id');
		$auth=$authmenu->check($uid,'cust_sendSms');
		if($auth != true){
			$this->error('权限不足');
		}
		$data =  DB::name('cust_yixiang')->where('is_del = 0 and  phone REGEXP "^[1][35678][0-9]{9}$"')->field('phone,name')->group('phone')->order('id')->select();
		foreach($data as $k=>$v){
			$send = send_sms($v['phone'], 1, ['code'=>$v['name']]);
			if($send['Message'] != 'OK'){
				$this->error($v['name'].'的电话号有问题');
				//return false;
			}
		}if($send['Message'] == 'OK'){
			$this->success('发送成功',url('index/index/index',array('con'=>'customer','act'=>'index')));
		}
	}


	public function duanxin()
	{
		$send = send_sms('15829641743',  1, ['code'=>'李瑞强']);
			if($send['Message'] != 'OK'){
				$this->error($v['name'].'的电话号有问题');
				//return false;
			}else{
				$this->success('chengg');
			}
	}

}

?>